// Code generated by smithy-go-codegen DO NOT EDIT.

package s3

import (
	
	awsmiddleware 
	
	internalChecksum 
	s3cust 
	
	
	smithyhttp 
)

// This action uses the encryption subresource to configure default encryption and
// Amazon S3 Bucket Key for an existing bucket. Default encryption for a bucket can
// use server-side encryption with Amazon S3-managed keys (SSE-S3) or customer
// managed keys (SSE-KMS). If you specify default encryption using SSE-KMS, you can
// also configure Amazon S3 Bucket Key. When the default encryption is SSE-KMS, if
// you upload an object to the bucket and do not specify the KMS key to use for
// encryption, Amazon S3 uses the default Amazon Web Services managed KMS key for
// your account. For information about default encryption, see Amazon S3 default
// bucket encryption
// (https://docs.aws.amazon.com/AmazonS3/latest/dev/bucket-encryption.html) in the
// Amazon S3 User Guide. For more information about S3 Bucket Keys, see Amazon S3
// Bucket Keys (https://docs.aws.amazon.com/AmazonS3/latest/dev/bucket-key.html) in
// the Amazon S3 User Guide. This action requires Amazon Web Services Signature
// Version 4. For more information, see  Authenticating Requests (Amazon Web
// Services Signature Version 4)
// (https://docs.aws.amazon.com/AmazonS3/latest/API/sig-v4-authenticating-requests.html).
// To use this operation, you must have permissions to perform the
// s3:PutEncryptionConfiguration action. The bucket owner has this permission by
// default. The bucket owner can grant this permission to others. For more
// information about permissions, see Permissions Related to Bucket Subresource
// Operations
// (https://docs.aws.amazon.com/AmazonS3/latest/userguide/using-with-s3-actions.html#using-with-s3-actions-related-to-bucket-subresources)
// and Managing Access Permissions to Your Amazon S3 Resources
// (https://docs.aws.amazon.com/AmazonS3/latest/userguide/s3-access-control.html)
// in the Amazon S3 User Guide. Related Resources
//
// * GetBucketEncryption
// (https://docs.aws.amazon.com/AmazonS3/latest/API/API_GetBucketEncryption.html)
//
// *
// DeleteBucketEncryption
// (https://docs.aws.amazon.com/AmazonS3/latest/API/API_DeleteBucketEncryption.html)
func ( *Client) ( context.Context,  *PutBucketEncryptionInput,  ...func(*Options)) (*PutBucketEncryptionOutput, error) {
	if  == nil {
		 = &PutBucketEncryptionInput{}
	}

	, ,  := .invokeOperation(, "PutBucketEncryption", , , .addOperationPutBucketEncryptionMiddlewares)
	if  != nil {
		return nil, 
	}

	 := .(*PutBucketEncryptionOutput)
	.ResultMetadata = 
	return , nil
}

type PutBucketEncryptionInput struct {

	// Specifies default encryption for a bucket using server-side encryption with
	// Amazon S3-managed keys (SSE-S3) or customer managed keys (SSE-KMS). For
	// information about the Amazon S3 default encryption feature, see Amazon S3
	// Default Bucket Encryption
	// (https://docs.aws.amazon.com/AmazonS3/latest/dev/bucket-encryption.html) in the
	// Amazon S3 User Guide.
	//
	// This member is required.
	Bucket *string

	// Specifies the default server-side-encryption configuration.
	//
	// This member is required.
	ServerSideEncryptionConfiguration *types.ServerSideEncryptionConfiguration

	// Indicates the algorithm used to create the checksum for the object when using
	// the SDK. This header will not provide any additional functionality if not using
	// the SDK. When sending this header, there must be a corresponding x-amz-checksum
	// or x-amz-trailer header sent. Otherwise, Amazon S3 fails the request with the
	// HTTP status code 400 Bad Request. For more information, see Checking object
	// integrity
	// (https://docs.aws.amazon.com/AmazonS3/latest/userguide/checking-object-integrity.html)
	// in the Amazon S3 User Guide. If you provide an individual checksum, Amazon S3
	// ignores any provided ChecksumAlgorithm parameter.
	ChecksumAlgorithm types.ChecksumAlgorithm

	// The base64-encoded 128-bit MD5 digest of the server-side encryption
	// configuration. For requests made using the Amazon Web Services Command Line
	// Interface (CLI) or Amazon Web Services SDKs, this field is calculated
	// automatically.
	ContentMD5 *string

	// The account ID of the expected bucket owner. If the bucket is owned by a
	// different account, the request fails with the HTTP status code 403 Forbidden
	// (access denied).
	ExpectedBucketOwner *string

	noSmithyDocumentSerde
}

type PutBucketEncryptionOutput struct {
	// Metadata pertaining to the operation's result.
	ResultMetadata middleware.Metadata

	noSmithyDocumentSerde
}

func ( *Client) ( *middleware.Stack,  Options) ( error) {
	 = .Serialize.Add(&awsRestxml_serializeOpPutBucketEncryption{}, middleware.After)
	if  != nil {
		return 
	}
	 = .Deserialize.Add(&awsRestxml_deserializeOpPutBucketEncryption{}, middleware.After)
	if  != nil {
		return 
	}
	if  = addSetLoggerMiddleware(, );  != nil {
		return 
	}
	if  = awsmiddleware.AddClientRequestIDMiddleware();  != nil {
		return 
	}
	if  = smithyhttp.AddComputeContentLengthMiddleware();  != nil {
		return 
	}
	if  = addResolveEndpointMiddleware(, );  != nil {
		return 
	}
	if  = v4.AddComputePayloadSHA256Middleware();  != nil {
		return 
	}
	if  = addRetryMiddlewares(, );  != nil {
		return 
	}
	if  = addHTTPSignerV4Middleware(, );  != nil {
		return 
	}
	if  = awsmiddleware.AddRawResponseToMetadata();  != nil {
		return 
	}
	if  = awsmiddleware.AddRecordResponseTiming();  != nil {
		return 
	}
	if  = addClientUserAgent();  != nil {
		return 
	}
	if  = smithyhttp.AddErrorCloseResponseBodyMiddleware();  != nil {
		return 
	}
	if  = smithyhttp.AddCloseResponseBodyMiddleware();  != nil {
		return 
	}
	if  = swapWithCustomHTTPSignerMiddleware(, );  != nil {
		return 
	}
	if  = addOpPutBucketEncryptionValidationMiddleware();  != nil {
		return 
	}
	if  = .Initialize.Add(newServiceMetadataMiddleware_opPutBucketEncryption(.Region), middleware.Before);  != nil {
		return 
	}
	if  = addMetadataRetrieverMiddleware();  != nil {
		return 
	}
	if  = addPutBucketEncryptionInputChecksumMiddlewares(, );  != nil {
		return 
	}
	if  = addPutBucketEncryptionUpdateEndpoint(, );  != nil {
		return 
	}
	if  = addResponseErrorMiddleware();  != nil {
		return 
	}
	if  = v4.AddContentSHA256HeaderMiddleware();  != nil {
		return 
	}
	if  = disableAcceptEncodingGzip();  != nil {
		return 
	}
	if  = addRequestResponseLogging(, );  != nil {
		return 
	}
	return nil
}

func ( string) *awsmiddleware.RegisterServiceMetadata {
	return &awsmiddleware.RegisterServiceMetadata{
		Region:        ,
		ServiceID:     ServiceID,
		SigningName:   "s3",
		OperationName: "PutBucketEncryption",
	}
}

// getPutBucketEncryptionRequestAlgorithmMember gets the request checksum algorithm
// value provided as input.
func ( interface{}) (string, bool) {
	 := .(*PutBucketEncryptionInput)
	if len(.ChecksumAlgorithm) == 0 {
		return "", false
	}
	return string(.ChecksumAlgorithm), true
}

func ( *middleware.Stack,  Options) error {
	return internalChecksum.AddInputMiddleware(, internalChecksum.InputMiddlewareOptions{
		GetAlgorithm:                     getPutBucketEncryptionRequestAlgorithmMember,
		RequireChecksum:                  true,
		EnableTrailingChecksum:           false,
		EnableComputeSHA256PayloadHash:   true,
		EnableDecodedContentLengthHeader: true,
	})
}

// getPutBucketEncryptionBucketMember returns a pointer to string denoting a
// provided bucket member valueand a boolean indicating if the input has a modeled
// bucket name,
func ( interface{}) (*string, bool) {
	 := .(*PutBucketEncryptionInput)
	if .Bucket == nil {
		return nil, false
	}
	return .Bucket, true
}
func ( *middleware.Stack,  Options) error {
	return s3cust.UpdateEndpoint(, s3cust.UpdateEndpointOptions{
		Accessor: s3cust.UpdateEndpointParameterAccessor{
			GetBucketFromInput: getPutBucketEncryptionBucketMember,
		},
		UsePathStyle:                   .UsePathStyle,
		UseAccelerate:                  .UseAccelerate,
		SupportsAccelerate:             true,
		TargetS3ObjectLambda:           false,
		EndpointResolver:               .EndpointResolver,
		EndpointResolverOptions:        .EndpointOptions,
		UseARNRegion:                   .UseARNRegion,
		DisableMultiRegionAccessPoints: .DisableMultiRegionAccessPoints,
	})
}